home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kompuutteri Kaikille K-CD 2002 #8
/
K-CD_2002-08.iso
/
WatzNew
/
data.cab
/
HTTP GET.pl
< prev
next >
Wrap
Text File
|
2000-07-02
|
2KB
|
58 lines
#%DESCRIPTION%|=|Retrieves the specified document via HTTP and searches text with regular expression. Handles automatic browser redirection.
#%URL%|?|http://www.yoursite.com/path/file.ext?params|Document URL (http:// only)
#%AUTO_REDIRECT%|?|1|Handle auto-redirection? ('1' = yes, otherwise no)
#%REG_EXP%|?|<TITLE>(.*?)</TITLE>|Regular Expression
#%MAX_MATCHES%|?|1|How many matches to allow?
#%MSG_TEMPLATE%|?|Title: $1|Message template for each match
#%TITLE%|=|HTTP GET %URL%
#%MESSAGE%|=|%1
# ------------------------------------------------------------------------------
# General HTTP GET script by A.I.Studio / Igor Afanasyev
# ------------------------------------------------------------------------------
require 'http.lib';
# ------------------------------------------------------------------------------
$Url = $ENV{'URL'};
($Url eq '') && &ERR('URL is not defined');
$RegExp = $ENV{'REG_EXP'};
#($RegExp eq '') && &ERR('REG_EXP is not defined');
$Message = $ENV{'MSG_TEMPLATE'};
($Message eq '') && ($Message = '$1');
$AutoRedirect = ($ENV{'AUTO_REDIRECT'} eq '1');
$MaxMatches = $ENV{'MAX_MATCHES'};
($MaxMatches == 0) && ($MaxMatches = 1);
# ------------------------------------------------------------------------------
if ($AutoRedirect) {
($_,$Url) = &HttpGetUrlAutoRedirect($Url, 1);
} else {
&HttpGetUrl($Url, 1);
}
undef my $out;
my $re = qr|$RegExp|si;
if ($RegExp ne '') {
while (($HttpBody =~ m|$re|g) && ($MaxMatches > 0)) {
my $e = '$out .= "'.$Message.'"';
eval($e);
$MaxMatches--;
}
$out = &ExpandUrls(&Squeeze($out),$Url);
} else {
$out = 'REG_EXP is not defined';
}
($out eq '') && ($out = 'No pattern match found');
&MSG($out);
&MSG($Url);